package LeetCode1;

import java.util.Stack;

/**
 * 用两个栈实现队列
 *
 * @author 是阿秋啊
 * @date 2022/03/28 18:07
 **/
public class OfferNum09 {
    Stack<Integer> s1 = new Stack<>();
    Stack<Integer> s2 = new Stack<>();

    public void appendTail(int value) {
        while (!s1.isEmpty()) {
            s2.push(s1.pop());
        }
        s1.push(value);
        while (!s2.isEmpty()) {
            s1.push(s2.pop());
        }
    }

    public int deleteHead() {
        if (s1.isEmpty()) {
            return -1;
        }
        return s1.pop();
    }
}
